import { mapToOptions } from 'utils';

export const OPT_SUCCESS_MSG = '操作成功';
export const OPT_ERROR_MSG = '操作失败';

interface IOption {
  value: number | string;
  label: string;
}

export const USER_TYPE_MAP: { [key: string]: string } = {
  user: '普通用户',
  vip: '会员用户',
  staff: '内部人员',
};
//是否续费
export const USER_TYPE_RENEW: { [key: string]: string } = {
  user: '已经续费',
  vip: '未续费',
};
export const USER_TYPE_OPTIONS: Array<IOption> = [
  { value: 'user', label: '普通用户' },
  { value: 'vip', label: '会员用户' },
  { value: 'staff', label: '内部人员' },
];

type OpenTypeKey = 1 | 2 | 3;
export const OPEN_TYPE_MAP: Record<OpenTypeKey, string> = {
  1: '已开通',
  2: '未开通',
  3: '已取消',
};

// 订单类型
type OrderTypeKey = 1 | 2 | 3 | 4 | 8 | 9 | 10 | 99;
export const ORDER_TYPE_MAP: Record<OrderTypeKey, string> = {
  1: '正常',
  2: '仅创建',
  3: '赠送',
  4: '测试',
  8: '补偿',
  9: '试用',
  10: '补单',
  99: '异常',
};


export const ORDER_STATUS_MAPS = {
  1: '正常',
  99: '异常'
}
// 订单类型选项，用于 select 组件
export const ORDER_TYPE_OPTIONS: { label: string; value: number }[] = [
  { label: '正常', value: 1 },
  { label: '异常', value: 99 },
  { label: '试用', value: 9 }
];

// 工具函数：根据 value 获取 label
export const getOrderTypeLabel = (value: number): string => {
  const option = ORDER_TYPE_OPTIONS.find((item) => item.value === value);
  return option ? option.label : '';
};

type PackageTypeKey = 1 | 3 | 6;
export const PACKAGE_TYPE_MAP: Record<PackageTypeKey, string> = {
  1: '动态GB',
  6: '不限量',
  3: '静态',
};

// 使用工具函数自动生成选项数组
export const PACKAGE_TYPE_OPTIONS = mapToOptions(PACKAGE_TYPE_MAP);

export interface PromotionItem {
  label: string;
  value: string;
}
export const PROMOTION_MAP: PromotionItem[] = [
  {
    label: 'Google',
    value: 'Google',
  },
  {
    label: 'Facebook',
    value: 'Facebook',
  },
  {
    label: 'Twitter',
    value: 'Twitter',
  },
  {
    label: 'Bing',
    value: 'Bing',
  },
];

export const IS_FIRST_PAY_MAPS = {
  1: '首购',
  2: '复购'
}

export interface EnableItem {
  label: string;
  value: number | string;
}
export const ENABLE_MAP: EnableItem[] = [
  {
    label: '启用',
    value: 1,
  },
  {
    label: '禁用',
    value: 2,
  },
];

// 将 ENABLE_MAP 转换为对象格式，然后生成选项
export const ENABLE_MAP_OBJECT = {
  1: '启用',
  2: '禁用',
};
export const ENABLE_OPTIONS = mapToOptions(ENABLE_MAP_OBJECT);

export const OPT_MAP_ENUM: { [key: string]: string } = {
  success: '操作成功',
  error: '操作失败',
  reset: '重置成功',
  export: '导出成功',
};

// 渠道推广平台
export const CHANNEL_PROMOTION_MAP: EnableItem[] = [
  {
    label: '论坛',
    value: '论坛',
  },
  {
    label: '反检测浏览器',
    value: '反检测浏览器',
  },
  {
    label: '社交媒体',
    value: '社交媒体',
  },
  {
    label: '社群',
    value: '社群',
  },
  {
    label: '跨境导航',
    value: '跨境导航',
  },
  {
    label: '优惠券平台',
    value: '优惠券平台',
  },
  {
    label: '博客网站',
    value: '博客网站',
  },
  {
    label: '工具平台',
    value: '工具平台',
  },
  {
    label: '运营推广',
    value: '运营推广',
  },
  {
    label: '其他',
    value: '其他',
  },
];

export const ORDER_STATUS_MAP: any = {
  1: '官网订单',
  2: '后台订单',
};

export const PLATFORM_OPTIONS = [
  {
    label: '官网',
    value: 1
  },
  {
    label: '后台',
    value: 2
  }
]

export const STATIC_PROVIDER_MAP: any = {
  8: '杭州混播',
  11: 'SPARK静态',
  25: ' LycheeIP静态',
  27: 'Lumi静态',
  31: '自建段',
}



export const ALL_PROVIDER_MAP: any = {
  1: '杭州混播',
  2: '711自建（基于杭州混播）',
  3: 'IPWO',
  4: 'IPMOYU',
  // 5:'广州一家路由器',
  6: '蜘蛛静态',
  // 7:'proxy-seller',
  8: 'IPFLY静态',
  9: 'IPFLY动态',
  10: 'LUMI动态',
  11: 'SPARK静态',
  12: 'IPWO USST',
  13: 'IPWO USMJ',
  14: '其他预留',
  15: 'STARRY 数量',
  16: 'NETNUT 短效',
  17: 'MOYU_MIX 混播',
  18: '杭州纯 US 流量 ',
  19: 'NETNUT 短效',
  20: 'NETNUT 长效+短效',
  21: 'lumimix 混播',
  22: 'moyumix 混播',
  // 23:'u14706mix',
  24: 'IPFLY WANZI M11 流量 ',
  25: 'LycheeIP 静态',
  // 26:'liuchao ucloud r1',
  27: 'lumi_static ',
  28: 'HH30w',
  29: 'lumi_plus 大池子',
  30: '需手动发货订单',
  31: 'SX 自建段 静态',
  32: 'jm',
  33: 'tony 静态',
  34: '与杭州合作越南自建'
};

export const ALL_PROVIDER_OPTIONS = mapToOptions(ALL_PROVIDER_MAP)

export const STATIC_PROVIDER_OPTIONS = mapToOptions(STATIC_PROVIDER_MAP)
export const ALL_SOURCE_OPTIONS = [...PLATFORM_OPTIONS, ...PROMOTION_MAP, ...CHANNEL_PROMOTION_MAP]